import { i18n } from '@/locales'
import { ref } from 'vue'
import { apiInit } from '@/services'
const { $t } = i18n
const api = apiInit()
const newsTitle = ref('')
const noticeTitle = ref('')
const ruleTitle = ref('')
const list = ref()
const local: any = localStorage.getItem('locale')?.substr(0, 2)
const tabList: any = ref([])
// 获取面包屑导航数据
const getMenuTitle = async () => {
	const { data } = await api.portalExtend.POSTInfoModuleList({})
	localStorage.setItem('infoModuleList', JSON.stringify(data))
	list.value = data
	for (const key in list.value) {
		if (list.value[key]?.module_id === 'NEWS') {
			newsTitle.value = list.value[key].name
		}
		if (list.value[key]?.module_id === 'NOTICE') {
			noticeTitle.value = list.value[key].name
		}
		if (list.value[key]?.module_id === 'RULES') {
			ruleTitle.value = list.value[key].name
		}
	}
	tabList.value = [
		{
			label: '新闻',
			labelCenter: newsTitle.value[local],
			labelDetails: $t('informationPortal.newsDetails', '新闻详情'),
			value: 'news',
		},
		{
			label: '公告',
			labelCenter: noticeTitle.value[local],
			labelDetails: $t('informationPortal.AnnouncementDetails', '公告详情'),
			value: 'notifications',
		},
		{
			label: '规章制度',
			labelCenter: ruleTitle.value[local],
			labelDetails: $t('informationPortal.regulationsDetails', '规章制度详情'),
			value: 'regulations',
		},
		{
			label: '轮播',
			labelDetails: $t('informationPortal.lunbotuDetails', '轮播图详情'),
			value: 'carousel',
		},
	]
	return tabList.value
}

export default getMenuTitle
